import Vue from 'vue'
import Router from 'vue-router'
import Index from '@/view/Index'
import Me from '@/view/Me'
import Course from '@/view/Course'
import Buy from '@/view/Buy'
import Bind from '@/view/Bind'
import Error404 from '@/view/Error404'
import Error500 from '@/view/Error500'

Vue.use(Router)

export default new Router({
  mode: 'history',
  routes: [
    {
      path: '/index',
      name: 'Index',
      component: Index
    },
    {
      path: '/me',
      name: 'Me',
      component: Me
    },
    {
      path: '/course/:id/:randId',
      name: 'Course',
      component: Course
    },
    {
      path: '/category/:id/:randId',
      name: 'Category',
      component: Course
    },
    {
      path: '/buy/:id',
      name: 'Buy',
      component: Buy
    },
    {
      path: '/bind/:orderSN',
      name: 'Bind',
      component: Bind
    },
    {
      path: '/error/404',
      name: 'Error404',
      component: Error404
    },
    {
      path: '/error/500',
      name: 'Error500',
      component: Error500
    },
    {
      path: '/',
      component: Index,
      name: 'Default'
    },
    { path: '*', redirect: '/error/404' }
  ],
  /* eslint-disable */
  scrollBehavior (to, from, savedPosition) {
    return { x: 0, y: 0 }
  }
})
